package com.md24housecall.dialog;

import java.util.ArrayList;

import com.md24housecall.activity.R;
import com.md24housecall.manager.SkypeManager;
import com.md24housecall.model.Doctor;
import com.md24housecall.util.MyLog;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.ArrayAdapter;


public class DialogListDoctor {
	private Context mContext;
	private ArrayAdapter<String> adapter;
	private AlertDialog alertDialog;
	private SkypeManager skypeManager=SkypeManager.getInstance();
	
	public DialogListDoctor(Context context,final ArrayList<Doctor>listDoctors){
		mContext=context;
		adapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1);
		for(Doctor doctor:listDoctors){
			adapter.add(doctor.getDoctorName());
		}
		
		alertDialog=new AlertDialog.Builder(mContext).setAdapter(adapter,new OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				MyLog.d("DucNM","skype: "+listDoctors.get(which).getDoctorSkype());
				skypeManager.callViaSkype(mContext, listDoctors.get(which).getDoctorSkype());
			}
		}).setNegativeButton(context.getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.dismiss();
			}
		}).create();
		alertDialog.setTitle(context.getString(R.string.dlg_choose_doctor_title));
	}
	
	public void show(){
		alertDialog.show();
	}
	
	public void close(){
		alertDialog.dismiss();
	}
}
